<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
class Email{
	
    function __construct()
    {
        require_once(APPPATH.'libraries/email/class.phpmailer.php');
        $this->ci =& get_instance();
        $this->email = new PHPMailer();
        $this->email->IsSMTP();
        $this->email->SMTPAuth=true;
        $this->email->Host="smtp.exmail.qq.com";//smtp.email.huiyingdai.com
        $this->email->Port=25;
        $this->email->Username="tan66_email@tan66.com";
        $this->email->Password="Tan123321";
        $this->email->From="tan66_email@tan66.com";
        $this->email->FromName = '弹溜溜官方';
        $this->ci->load->model('sms_model');
        $this->sign = "【弹溜溜】";
    }
    //发送邮件
     /*
      * $email  邮件地址；
      * $sub    主题
      * $body   内容
      */
     public  function send($email,$sub,$body,$ip){
        $this->email->Subject=$sub;
        $this->email->WordWrap=50;
        $this->email->CharSet = "utf-8";
        $this->email->MsgHTML($body);
        $this->email->AddAddress($email);
        $this->email->IsHTML(true);
        $statusCode = $this->email->Send();
        
        $data['account'] = $email;
        $data['content'] = $body;
        $data['status'] = $statusCode;
        $data['type'] = 2;
        $data['send_type'] = 1;
        $data['ip'] = $ip;
        $data['create_date'] = date("Ymd");
        $data['create_time'] = time();
        $this->ci->sms_model->insert($data);
        $mess = array();
        if($statusCode){
            $mess['info'] = '短信已发送';
            $mess['status'] = 0;
            return $mess;
        }else{
            $mess['info'] = $this->email->ErrorInfo;
            $mess['status'] = 1;
            return $mess;
        }
     }
}